/**
 * 
 */
package info.niwota.group;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * @author qiangli
 * @param <T>
 * 
 */
public class MenuAdapter extends ArrayAdapter<Object> {
	private int[] icons;
	private String[] labels;
	private LayoutInflater inflater;

	public MenuAdapter(Activity context, int[] icons, String[] labels) {
		super(context, R.layout.menu_item, R.id.menu_item_label, labels);
		this.icons = icons;
		this.labels = labels;
		inflater = LayoutInflater.from(context);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View row = inflater.inflate(R.layout.menu_item, null);
		ImageView icon = (ImageView) row.findViewById(R.id.menu_item_icon);
		TextView label = (TextView) row.findViewById(R.id.menu_item_label);
		icon.setImageResource(icons[position]);
		label.setText(labels[position]);
		return (row);
	}
}
